# name : Retrieve the Program Name Currently Running in Batch Mode or Interactively
# key : current.running.program
# contributor: Shuguang Sun
# --
%put The current program is %sysfunc(getoption(sysin));
%put %sysget(SAS_EXECFILENAME);

%macro pname;

  data _null_;
    set sashelp.vextfl;
    if (substr(fileref,1,3)='_LN' or substr(fileref,1,3)='#LN' or
      substr(fileref,1,3)='SYS') AND index(upcase(xpath),'.SAS')>0 then do;
      call symputx('pgmname',xpath,'g');
      stop;
      end;
  run;
  %mend pname;

%pname;

%put pgmname=&pgmname;